<script type="text/javascript">
function updateCharCount()
{
<?php if (($GLOBALS['browser']->isBrowser('msie') &&
           $GLOBALS['browser']->getMajor() >= 4) ||
          ($GLOBALS['browser']->isBrowser('mozilla') &&
           $GLOBALS['browser']->getMajor() >= 5)): ?>
    document.getElementById('charcount').innerHTML = document.getElementById('isbn').value.replace(/[\r\n]/g, '').length;
<?php endif; ?>
}
</script>
<?php echo $cManager->getJavaScript('item', 'item_category') ?>
<form method="post" name="item" action="isbn.php">
<?php Util::pFormInput() ?>
<input type="hidden" name="actionID" value="save_item" />
<input type="hidden" name="item" value="<?php echo htmlspecialchars($item_id) ?>" />
<input type="hidden" name="new_category" value="" />
<input type="hidden" name="itemlist_original" value="<?php echo htmlspecialchars($itemlist_id) ?>" />
<?php if ($prefs->isLocked('default_collection') || count($collections) <= 1): ?>
<input type="hidden" name="collection_target" value="<?php echo htmlspecialchars($itemlist_id) ?>" />
<?php endif; ?>
<h1 class="header"><?php echo htmlspecialchars($title) ?></h1>

<table cellspacing="0" width="100%">
<tr>
    <td class="item" nowrap="nowrap" align="right" valign="top"><strong><?php
    echo Horde::label('isbn', _("ISBN or EAN")) ?></strong>&nbsp;</td>
    <td class="item">
        <input type="text" name="isbn" id="isbn" size="15" maxlength="13" value="<?php echo htmlspecialchars($isbn)?>" 
          onchange="updateCharCount()" onclick="updateCharCount()" onkeypress="setTimeout('updateCharCount()', 1)" />
          <span id="charcount"><?php String::length($isbn) ?></span>
    </td>
    <td class="item" width="100%">&nbsp;</td>
</tr>
<?php if (!$prefs->isLocked('default_collection') && count($collections) > 1): ?>
<tr>
    <td class="item nowrap" align="right" valign="top"><strong><?php echo Horde::label('collection_target', _("_Collection")) ?></strong>&nbsp;</td>
    <td class="item">

    <select id="collection_target" name="collection_target">
    <?php
    foreach ($collections as $id => $collection) {
        $sel = ($id == $itemlist_id) ? ' selected="selected"' : '';
        printf('<option value="%s"%s>%s</option>',
               htmlspecialchars($id), $sel, htmlspecialchars($collection->get('name'))) . "\n";
    } ?>
    </select>

    </td>
    <td class="item">&nbsp;</td>
</tr>
<?php endif; ?>
<tr>
    <td class="item" align="right" valign="top"><strong><?php echo Horde::label('item_category', _("C_ategory")) ?></strong>&nbsp;</td>
    <td class="item"><?php echo $cManager->getSelect('item_category', $item_category) ?></td>
    <td class="item">&nbsp;</td>
</tr>
<tr>
    <td class="item" align="right"><input type="submit" class="button" value="<?php echo _("Save") ?>" onclick="return checkCategory();" /></td>
    <td class="item" align="right">
        <input type="reset" class="button" value="<?php echo _("Undo changes") ?>" />&nbsp;
<?php
if ($item_id):
    $itemurl = Util::addParameter('item.php', array('item' => $item_id,
                                                    'itemlist' => $itemlist_id));

    $share = $GLOBALS['groo_shares']->getShare($itemlist_id);
    if (!is_a($share, 'PEAR_Error') && $share->hasPermission(Auth::getAuth(), PERMS_DELETE)):
?>
        <input type="button" class="button" value="<?php echo _("Delete this item") ?>" onclick="window.location='<?php echo addslashes(Horde::applicationUrl(Util::addParameter($itemurl, 'actionID', 'delete_items'))) ?>';" />&nbsp;
<?php endif; endif; ?>
    </td>
    <td class="item">&nbsp;</td>
</tr>
</table>
</form>
<script type="text/javascript">
<!--
try {
    document.getElementById("isbn").focus();
} catch(e) {}
//-->
</script>
